package cn.sytton.taffe.auth.mapper;

import cn.sytton.taffe.auth.entity.AuthUserEntity;
import cn.sytton.taffe.framework.base.mapper.MasterSqlMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * 认证Mapper
 *
 * @author skyrock
 */
public interface SecurityMapper extends MasterSqlMapper<AuthUserEntity> {

    @Select("select userId, userCode, userName, loginName, password, userStatus, cellphone, email, expiryDate from sys_user where loginName = #{loginName}")
    AuthUserEntity findUserByLoginName(@Param("loginName") String loginName);

    @Select("select userId, userCode, userName, loginName, password, userStatus, cellphone, email, expiryDate from sys_user where cellphone = #{cellphone}")
    AuthUserEntity findUserByCellphone(@Param("cellphone") String cellphone);

    @Select("select userId, userCode, userName, loginName, password, userStatus, cellphone, email, expiryDate from sys_user where userId = #{userId}")
    AuthUserEntity findUserById(@Param("userId") String userId);

    @Select("select roleId from sys_role_user where userId = #{userId}")
    Set<String> findRoleIds(@Param("userId") String userId);
}
